package cn.iocoder.yudao.module.blog.dal.mysql.post;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.blog.dal.dataobject.post.BlogPostDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.blog.controller.admin.post.vo.*;

/**
 * 帖子 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface BlogPostMapper extends BaseMapperX<BlogPostDO> {

    default PageResult<BlogPostDO> selectPage(BlogPostPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BlogPostDO>()
                .eqIfPresent(BlogPostDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogPostDO::getModuleId, reqVO.getModuleId())
                .eqIfPresent(BlogPostDO::getIsTop, reqVO.getIsTop())
                .eqIfPresent(BlogPostDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BlogPostDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlogPostDO::getId));
    }

    default List<BlogPostDO> selectList(BlogPostExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BlogPostDO>()
                .eqIfPresent(BlogPostDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogPostDO::getModuleId, reqVO.getModuleId())
                .eqIfPresent(BlogPostDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(BlogPostDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlogPostDO::getId));
    }

}
